package com.aionengine.gameserver.services.custom;

import com.aionemu.commons.utils.Rnd;
import com.aionengine.gameserver.model.gameobjects.player.Player;
import com.aionengine.gameserver.services.item.ItemService;
import com.aionengine.gameserver.utils.PacketSendUtility;


/**
 * @author cheatkiller
 *
 */
public class PVPExchangeService {
	
	public static void exchangeMedal(Player player) {
		if (hasItem(player, 186000147)) {
			if (player.getInventory().isFull() || player.getInventory().isFullSpecialCube()) {
				PacketSendUtility.sendMessage(player, "Su inventario es completo!");
				return;
			}
			player.getInventory().decreaseByItemId(186000147, 1);
			int rnd = Rnd.get(0, 100);
	     if (rnd < 15)
	    	 ItemService.addItem(player, 186000242, 1);
	     else
                 PacketSendUtility.sendMessage(player, "Refundido fallado! Otra vez!");
		}
		else
			PacketSendUtility.sendMessage(player, "No tienes medallas! :-(");
	}
	
	private static boolean hasItem(Player player, int itemId) {
    return player.getInventory().getItemCountByItemId(itemId) > 0;
	}

}
